<?php



namespace App\Zesow\Cache\Impl;

use Illuminate\Support\Facades\Cache;
use App\Services\Other\Interfaces\FooterNavServiceInterface;

class FooterNavCache
{

    public const KEY_NAME = 'footer_navs';

    private $footerNavService;

    public function __construct(FooterNavServiceInterface $footerNavService)
    {
        $this->footerNavService = $footerNavService;
    }

    public function get(string $platform)
    {
        return Cache::get($this->key($platform), function () use ($platform) {
            return $this->footerNavService->all($platform);
        });
    }

    public function destroy(string $platform): void
    {
        Cache::forget($this->key($platform));
    }

    private function key(string $platform): string
    {
        return self::KEY_NAME . '-' . $platform;
    }

}
